#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>

#define FOR(i,a,n) for(int i=a;i<n;++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int a[100];
int sum=0;
bool done[70][50*70];
bool vis[70];
int n;
bool dfs(int maxGp,int gp,int pre)
{
    if(gp>=maxGp) return true;
    if(done[gp][pre]) return false;
    done[gp][pre] = true;
    REP(pos,n) if(!vis[pos])
    {
      // printf("gp=%d,pre=%d,pos=%d\n",gp,pre,pos);
        vis[pos]=true;
        if(pre+a[pos]==sum/maxGp) if(dfs(maxGp,gp+1,0)) return true;
        if(pre+a[pos]<sum/maxGp) if(dfs(maxGp,gp,pre+a[pos])) return true;
        while(pos+1<n&&a[pos]==a[pos+1]) pos++;
        vis[pos]=false;
    }
    return false;

}
bool cmp(int a,int b){return a>b;}
int main()
{
    while(cin>>n)
    {
        sum=0;
        if(!n)break;
        REP(i,n) scanf("%d",&a[i]),sum+=a[i];
        sort(a,a+n,cmp);
        FOR(i,1,sum+1) if(sum%i==0)
        {
           // printf("dfs maxGp=%d,len=%d\n",sum/i,i);
            REP(i,n) REP(j,50*n) done[i][j]=false;
            fill(vis,vis+70,false);
            if(dfs(sum/i,0,0))
            {
                cout<<i<<endl;
                break;
            }
        }
    }
	return 0;
}
//32 1 1 1 1 1 2 1 1 1 1 2 2 2 2 2 6 2 2 2 2 3 3 3 3 3 3 3 3 3 9 1 1
